package org.pada.ext.annotation;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * 扩展点枚举
 *
 * @author pengshen
 * @date 2023.12.29 16:14
 */
public enum SysExtPt implements IExtPt {

    EMPTY("", "", "");

    private static final String EMPTY_STRING = "";
    private final String x;
    private final String y;
    private final String z;

    SysExtPt(String x) {
        this.x = x;
        this.y = EMPTY_STRING;
        this.z = EMPTY_STRING;
    }

    SysExtPt(String x, String y) {
        this.x = x;
        this.y = y;
        this.z = EMPTY_STRING;
    }

    SysExtPt(String x, String y, String z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    @Override
    public String getIdentity() {
        return String.format("%s#%s#%s", Optional.ofNullable(x).orElse(EMPTY_STRING),
                Optional.ofNullable(y).orElse(EMPTY_STRING), Optional.ofNullable(z).orElse(EMPTY_STRING));
    }

    @Override
    public List<String> getParentIdentities() {
        List<String> parent = new ArrayList<>(2);
        parent.add(String.format("%s#%s#%s", Optional.ofNullable(x).orElse(""),
                Optional.ofNullable(y).orElse(EMPTY_STRING), EMPTY_STRING));
        parent.add(String.format("%s#%s#%s", Optional.ofNullable(x).orElse(EMPTY_STRING), EMPTY_STRING,
                EMPTY_STRING));
        parent.add(String.format("%s#%s#%s", EMPTY_STRING, EMPTY_STRING, EMPTY_STRING));
        return parent;
    }
}
